package com.example.batch.listen.write;

import com.example.batch.entity.Person;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.ItemWriteListener;

import java.util.List;

@Slf4j
public class PersonItemWriteListener implements ItemWriteListener<Person> {

    @Override
    public void beforeWrite(List<? extends Person> list) {
        log.info("数据库写入之前");
    }

    @Override
    public void afterWrite(List<? extends Person> list) {
        log.info("数据库写入之后");
    }

    @SneakyThrows
    @Override
    public void onWriteError(Exception e, List<? extends Person> list) {
        log.info("数据库写入异常");
    }
}
